#include<iostream>
#include<set>
#include<string>
#include<cmath>
using namespace std;
set<pair<int, string>> s;
int main()
{
    int n; cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        string name; cin >> name;
        int d; cin >> d;
        s.emplace(d, name);
        sum += d;
    }
    sum /= n;
    sum /= 2;
    string retname; int retd = 0;
    for (auto& x : s)
    {
        int i = x.first; string j = x.second;
        if (abs(i - sum) < abs(retd - sum))
        {
            retd = i; retname = j;
        }
    }

    cout << sum << " " << retname << endl;

    return 0;
}